import { ElNotification } from 'element-plus'

export default {
    dsn: '/trackweb',
    appName: 'cxh',
    debug: true,
    pv: true,
    performance: true,
    error: true,
    event: true,
    cacheMaxLength: 10,
    cacheWatingTime: 1000,

    // 查询埋点信息、清除埋点信息、获取埋点基础信息 不需要进行捕获
    ignoreRequest: [
        /getAllTracingList/,
        /cleanTracingList/,
        /getBaseInfo/,
        /getSourceMap/
    ],

    // 发送埋点数据后，拉起弹窗提示用户已发送
    afterSendData(data) {
        const { sendType, success, params } = data
        const message = `
        <div class='event-pop'>
          <div class='warning-text'>打开控制台可查看更多详细信息</div>
          <div>发送是否成功: ${success}</div>
          <div>发送方式: ${sendType}</div>
          <div>发送内容(只概括 eventType、eventId)
            ${params.eventInfo.reduce(
            (pre, item, index) => {
                pre += `
                <div class='pop-line'>
                  <span>${index + 1}</span>
                  <div>${item.eventType}(${sendEventType[item.eventType]})</div>
                  <div>${item.eventId}</div>
                </div>`
                return pre
            },
            `<div class='pop-line'>
                <div>eventType</div>
                <div>eventId</div>
              </div>`
        )}
          </div>
        </div>
      `
        // ElNotification({
        //     title: '发送一批数据到服务端',
        //     message,
        //     position: 'top-right',
        //     dangerouslyUseHTMLString: true
        // })
        console.log('发送一批数据到服务端');
        // @ts-ignore
        if (window.getAllTracingList) {
            // @ts-ignore
            window.getAllTracingList()
        }
    }
}